﻿<script setup lang="ts" name="Barcode">
import JsBarcode from 'jsbarcode'

const props = defineProps({
  tag: {
    type: String,
    default: 'canvas'
  },
  text: {
    type: String,
    default: null
  },
  // 完整配置 https://github.com/lindell/JsBarcode/wiki/Options
  options: {
    type: Object,
    default() {
      return {}
    }
  }
})

const barcodeRef = ref(null)

onMounted(() => {
  JsBarcode(barcodeRef.value, props.text, props.options)
})
</script>

<template>
  <component :is="tag" ref="barcodeRef" />
</template>
